<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="static/js/jquery-2.1.0.js"></script>
    <script>
        $(function(){
            $("#btn").click(function(){
                var data = {username:"jack",password:"admin"};
                $.ajax({
                    url:"doLogin",
                    type:"POST",
                    data:JSON.stringify(data),//json字符串
                    contentType:"application/json",
                    success:function(r){
                        console.log(r);
                        alert(r.toString());
                    }
                });

            });

        });
    </script>
</head>
<body>

  <button id="btn">点击我</button>

</body>
</html>